/*
 * Created: Author: Aléx Carvalho / Date: Feb 9, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-05-19 04:08:49 +0000 (Tue, 19 May 2015) $
 */
package com.cpm.wrapper;

import com.cpm.aggregate.Attribute;
import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class Weight implements Attribute<Short> {

    @Column(nullable = false)
    private Short weight;

    public Weight() {
    }

    public Weight(Short weight) {
        this.weight = weight;
    }

    @Override
    public Short getValue() {
        return weight;
    }

    public Weight plus(Weight value) {
        return plus(value.getValue());
    }
    
    public Weight plus(Short value) {
         value = (short) (weight != null ? value + weight : value);
         
        return new Weight(value);
    }
}
